import request from '@/utils/request'

/** *
 * 通过角色id获取角色对应的权限
 * @param roleId
 */
function findByRoleId(roleId) {
  return request({
    url: `/sapi/sys/role-permission/search/role-id/${roleId}`,
    method: 'post'
  })
}

/** *
 * 保存
 * @param data
 */
function save(roleId, rolePermissionList) {
  const postData = {}
  postData.roleId = roleId
  postData.rolePermissionListJson = JSON.stringify(rolePermissionList)
  return request({
    url: '/sapi/sys/role-permission/save',
    method: 'post',
    data: postData
  })
}

export default {
  findByRoleId,
  save
}
